package com.tingyuge.base.thread.wang.collection.blocking;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * Created by xiaodao
 * date: 2019/12/23
 *
 */
public class ArrayBlocking {
    /**
     * 有界的queue
     * FIFO
     * 数字一单固定,不能修改.
     * @param size
     * @param <T>
     * @return
     */
    public <T>ArrayBlockingQueue<T> create(int size){
        return new ArrayBlockingQueue<>(size);
    }

    public static void main(String[] args) throws InterruptedException {
        ArrayBlockingQueue<Object> objects = new ArrayBlockingQueue<>(5);
        objects.offer(1);
        objects.offer(1);
        objects.offer(1);
        objects.offer(1);
        boolean offer1 = objects.offer(1);
        System.out.println(offer1);
        System.out.println(objects.size());

        boolean offer = objects.offer(2);
        System.out.println(offer);
    }
}
